#include "vroute_worker.hpp"
#include "vroute_stack.hpp"
#include "vrouteErrors.hpp"
#include "vroute_data_in_outter.hpp"
#include "vroute_filter_outDispatcher.hpp"
#include "vroute_sys_statu.hpp"
#include "logger.hpp"
#include "vroute_filter_DataIn_Intergrate.hpp"
#include "vroute_filter_server_inner.hpp"

namespace vroute_stack
{
    CWorkerMgr* CWorkerMgr::_instance = nullptr;
    CWorkerMgr* CWorkerMgr::getInstance()
    {
        if(nullptr == _instance)
        {
            _instance = new CWorkerMgr();
        }
        return _instance;
    }

    void CWorkerMgr::releaseInstance()
    {
        if(_instance != nullptr)
        {
            delete _instance;
            _instance = nullptr;
        }
    }

    int CWorkerMgr::init(SystemStartType type)
    {
        CSysStatu::getInstance()->setStatu(sys_stu_type_running, (void*)sys_stu_run_init_workers);
        CDataInOutter::getInstance()->init();
        CFltOutDisp::getInstance()->init();
        CFltDataInInnerIntr::getInstance()->init();
        CFltServerInner::getInstance()->init();
        return e_vroute_sucess;
    }

    CWorkerMgr::CWorkerMgr()
    {
    }

    CWorkerMgr::~CWorkerMgr()
    {
        CSysStatu::getInstance()->setStatu(sys_stu_type_running, (void*)sys_stu_run_desting_workers);
        CDataInOutter::releaseInstance();
        CFltOutDisp::releaseInstance();
        CFltDataInInnerIntr::releaseInstance();
        CFltServerInner::releaseInstance();
    }
}